package config

// DatabaseConfig stores database connection options
type DatabaseConfig struct {
	Type         string `mapstructure:"type"`
	Host         string `mapstructure:"host"`
	Port         int    `mapstructure:"port"`
	User         string `mapstructure:"user"`
	Password     string `mapstructure:"password"`
	DatabaseName string `mapstructure:"databasename"`
	MaxIdleConns int    `mapstructure:"maxidleconns"`
	MaxOpenConns int    `mapstructure:"maxopenconns"`
}

// OauthConfig stores oauth service configuration options
type OauthConfig struct {
	AccessTokenLifetime  int `mapstructure:"accesstokenlifetime"`
	RefreshTokenLifetime int `mapstructure:"refreshtokenlifetime"`
	AuthCodeLifetime     int `mapstructure:"authcodelifetime"`
}

// SessionConfig stores oauth service configuration options
type SessionConfig struct {
	//secret
	Secret string `mapstructure:"secret"`
	Path   string `mapstructure:"path"`
	// MaxAge=0 means no 'Max-Age' attribute specified.
	// MaxAge<0 means delete cookie now, equivalently 'Max-Age: 0'.
	// MaxAge>0 means Max-Age attribute present and given in seconds.
	MaxAge int `mapstructure:"maxage"`
	// When you tag a cookie with the HttpOnly flag, it tells the browser that
	// this particular cookie should only be accessed by the server.
	// Any attempt to access the cookie from client script is strictly forbidden.
	HTTPOnly bool `mapstructure:"httponly"`
}

// Config stores all configuration options
type Config struct {
	Database      DatabaseConfig `mapstructure:"database"`
	Oauth         OauthConfig    `mapstructure:"oauth"`
	Session       SessionConfig  `mapstructure:"session"`
	ServerPort    int            `mapstructure:"serverport"`
	IsDevelopment bool           `mapstructure:"isdevelopment"`
}
